﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace CPPEI.Coolzon.UI.XProperty.Converters
{
    public class XStringToFontWeightConvert : IPropertyValueConverter
    {
        public object Convert(ConvertContext context, Metadata.ValueNode valueNode)
        {
            string strFontWeight = valueNode.Attributes["Value"];
            if (!string.IsNullOrEmpty(strFontWeight))
            {
                return (FontWeight)new FontWeightConverter().ConvertFromString(strFontWeight);
            }
            return null;
        }

        public Metadata.ValueNode ConvertBack(ConvertContext context, object value)
        {
            Metadata.ValueNode valueNode = new Metadata.ValueNode("FontWeight");
            valueNode.Attributes = new Dictionary<string, string>();
            valueNode.Attributes.Add("Value", System.Convert.ToString(value));
            return valueNode;
        }
    }
}
